package com.glr.company.dao;

import com.glr.company.entity.CompanyEntity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

/**
 * @author GLoRy
 * @date 2021/6/1 10:14
 */
public interface CompanyRepository extends JpaRepositoryImplementation<CompanyEntity, Integer> {

    /**
     * 根据id启用企业
     *
     * @param companyId 公司id
     */
    @Query(value = "update t_company c set c.status = 1 where c.company_id = ?1", nativeQuery = true)
    @Modifying
    void enable(Integer companyId);

    /**
     * 根据id禁用企业
     *
     * @param companyId 公司id
     */
    @Query(value = "update t_company c set c.status = 0 where c.company_id = ?1", nativeQuery = true)
    @Modifying
    void disable(Integer companyId);
}
